package edu.strategy.single.hitwall;

import java.awt.Color;

import robocode.AdvancedRobot;
import robocode.Event;
import edu.strategy.single.Single;

public class CrazyHitWall extends Single{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private boolean movingForward = false;
	public CrazyHitWall(AdvancedRobot advancedRobot) {
		super(advancedRobot);
	}
	
	@Override
	public void prepare() {
		super.getAdvancedRobot().setScanColor(new Color(255, 200, 200));
	}

	@Override
	public void work() {
		super.used();
		reverseDirection();
	}

	@Override
	public void work(Event e) {
		work();
	}
	
	private void reverseDirection() {
		if (movingForward) {
			super.getAdvancedRobot().setBack(40000);
			movingForward = false;
		} else {
			super.getAdvancedRobot().setAhead(40000);
			movingForward = true;
		}
		super.getAdvancedRobot().execute();
	}

	@Override
	public String toString() {
		return "CrazyHitWall";
	}

}
